import flash.geom.Point;
import flash.events.Event;
import flash.events.EventDispatcher;

class SquareModel extends AVerletModel
{

  public var _maxTileSize:Int;
  public var exit:Bool;
  public var Alpha:Float;

  private var _mapRow:Int;
  private var _mapColumn:Int;
  public function new()
  {
    super();
    _maxTileSize = Constants.MAX_TILE_SIZE;
    Alpha = 1;
  }
 public override function update()
  {
    if(acceleration_X == 0)
    { 
      vx = vx *.25;
    }
    if(acceleration_Y == 0)
    { 
      vy = vy *.25;
    }
    if(vx < -10)
    {  
      vx = -10;
    }
    if(vx > 10)
    {  
      vx = 10;
    }
    super.update();  
    Alpha = 1;
  }

 //Rows and column that the object occupies
  public var mapColumn(get_mapColumn,set_mapColumn):Int;
  public function get_mapColumn():Int
  {
     _mapColumn = Math.floor((xPos + width * 0.5) / _maxTileSize);
     return _mapColumn;
  }
  public function set_mapColumn(value:Int):Int
  {
     _mapColumn = value;
     return _mapColumn;
  }

  public var mapRow(get_mapRow,set_mapRow):Int;
  public function get_mapRow():Int
  {
     _mapRow = Math.floor((yPos + height * 0.5) / _maxTileSize);
     return _mapRow;
  }
  public function set_mapRow(value:Int):Int
  {
     _mapRow = value;
     return _mapRow;
  }
  //Top, bottom, left and right sides
  public var top(get_top,null):Int;
  public function get_top():Int
  {
     var top:Int = Math.floor(yPos / _maxTileSize);
     return top;
  }
  public var bottom(get_bottom,null):Int;
  public function get_bottom():Int
  {
     var bottom:Int = Math.floor((yPos + height) / _maxTileSize);
     return bottom;
  }
  public var left(get_left,null):Int;
  public function get_left():Int
  {
    
     var left:Int = Math.floor(xPos / _maxTileSize);
     return left;
  }
  public var right(get_right,null):Int;
  public function get_right():Int
  {
     var right:Int = Math.floor((xPos + width) / _maxTileSize);
     return right;
  }
  public var centerX(get_centerX,null):Int;
  public function get_centerX():Int
  {
     var centerX:Int = Math.floor((xPos + width * 0.5) / _maxTileSize);
     return centerX;
  }
  public var centerY(get_centerY,null):Int;
  public function get_centerY():Int
  {
     var centerY:Int = Math.floor((yPos + height * 0.5) / _maxTileSize);
     return centerY;
  }

}